<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp" %>
<html>
<head>
    <title>博客分类管理</title>
    <meta name="decorator" content="ani"/>
    <script type="text/javascript">
        var validateForm;
        var $categoryTreeTable; // 父页面table表格id
        var $topIndex;//openDialog的 dialog index
        function doSubmit(treeTable, index) {//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            if (validateForm.form()) {
                $categoryTreeTable = treeTable;
                $topIndex = index;
                jp.loading();
                $("#inputForm").submit();
                return true;
            }

            return false;
        }

        $(document).ready(function () {
            validateForm = $("#inputForm").validate({
                submitHandler: function (form) {
                    jp.post("${ctx}/blog/category/save", $('#inputForm').serialize(), function (data) {
                        if (data.success) {
                            $categoryTreeTable.jstree("refresh");
                            jp.success(data.msg);
                        } else {
                            jp.error(data.msg);
                        }

                        jp.close($topIndex);//关闭dialog
                    });
                    ;
                },
                errorContainer: "#messageBox",
                errorPlacement: function (error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });

        });
    </script>
</head>
<body class="bg-white">
<form:form id="inputForm" modelAttribute="category" method="post" class="form-horizontal">
    <form:hidden path="id"/>
    <sys:message content="${message}"/>
    <table class="table table-bordered table-condensed dataTables-example dataTable no-footer">
        <tbody>
        <tr>
            <td class="width-15 active"><label class="pull-right"><font color="red">*</font>类名：</label></td>
            <td class="width-35">
                <form:input path="name" htmlEscape="false" class="form-control required"/>
            </td>
            <td class="width-15 active"><label class="pull-right">类图：</label></td>
            <td class="width-35">
                <form:input path="image" htmlEscape="false" class="form-control"/>
            </td>
        </tr>
        </tr>
        <tr>
            <td class="width-15 active"><label class="pull-right">是否可用：</label></td>
            <td class="width-35">
				<form:select path="status" class="form-control ">
                	<form:options items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value"
                              htmlEscape="false"/>
            	</form:select>
                <span class="help-inline">“是”代表此数据可用，“否”则表示此数据不可用</span>
            </td>
            <td class="width-15 active"><label class="pull-right">排序：</label></td>
            <td class="width-35">
                <form:input path="sort" htmlEscape="false" class="form-control "/>
            </td>
        </tr>
        <tr>
            <td class="width-15 active"><label class="pull-right">父级编号：</label></td>
            <td class="width-35">
                <sys:treeselect id="parent" name="parent.id" value="${category.parent.id}" labelName="parent.name"
                                labelValue="${category.parent.name}"
                                title="父级分类" url="/blog/category/treeData" extId="${category.id}"
                                cssClass="form-control " allowClear="true"/>
            </td>
            <td class="width-15 active"><label class="pull-right">备注信息：</label></td>
            <td class="width-35">
                <form:textarea path="remarks" htmlEscape="false" rows="4" class="form-control "/>
            </td>
        </tr>
        </tbody>
    </table>
</form:form>
</body>
</html>